import sys, os

sys.path.append(os.getcwd())

from selenium.webdriver.common.by import By

from base.base_action import BaseAction


class DiscoverPage(BaseAction):
    # 发现页面

    # 发现页面title id = "com.chebao:id/title"
    discover_title = By.ID, "com.chebao:id/title"

    # 进行中 id = "com.chebao:id/putong_team"
    proceed_button = By.ID, "com.chebao:id/putong_team"

    # 已结束 id = "com.chebao:id/xinshou_team"
    finish_button = By.ID, "com.chebao:id/xinshou_team"

    # 详情列表 xpath = "//android.support.v7.widget.RecyclerView/android.widget.FrameLayout"
    discover_list = By.XPATH, "//android.support.v7.widget.RecyclerView/android.widget.FrameLayout"

    def __init__(self, driver):
        BaseAction.__init__(self, driver)

    def get_discover_title_text(self):
        # 获取发现页面title
        discover_title_text = self.find_element(self.discover_title).text
        return discover_title_text

    def click_proceed(self):
        # 点击进行中
        self.act_click(self.proceed_button)

    def click_finish(self):
        # 点击已结束
        self.act_click(self.finish_button)